a c++ code for scheduling tasks [closed]
Posted
by
scheduling
on Programmers
See other posts from Programmers
or by scheduling
Published on 2012-06-21T20:11:46Z
Indexed on
2012/06/21
21:23 UTC
Read the original article
Hit count: 132
c++
This code has no errors but then when i execute it, there is no output and the program automatically shuts down saying the program has stopped working.
#include<unistd.h>
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include<string.h>
int main()
{
char *timetoken;
char currtime[7];
char schedtime[7];
int i;
struct tm *localtimeptr;
strcpy(schedtime,"15:25:00");
while(6!=9)
{
time_t lt;
sleep(1);
lt = time(NULL);
localtimeptr = localtime(lt);
timetoken=strtok(asctime(localtimeptr)," ");
for(i=1;i<5;i++)
timetoken=strtok('\0'," ");
if(i==3)
{
strcpy(currtime,timetoken);
}
}
printf("The current time is: %s\n",currtime);
printf("We are waiting for: %s\n",schedtime);
if(!strcmp(currtime,schedtime))
{
printf("Time to do stuff \n");
system("C:\PROJECT X");
}
getch();
return 0;
}
© Programmers or respective owner